<?php

// Define path to application directory
defined('APPLICATION_PATH')
    || define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application'));

// Define application environment
defined('APPLICATION_ENV')
    || define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));

// Ensure library/ is on include_path
set_include_path(implode(PATH_SEPARATOR, array(
    realpath(APPLICATION_PATH . '/../library')
    . APPLICATION_PATH . '/application/models/'
    		. APPLICATION_PATH . '/application/forms/',
    get_include_path(),
)));

/** Zend_Application */
require_once 'Zend/Application.php';

// Create application, bootstrap, and run
$application = new Zend_Application(
    APPLICATION_ENV,
    APPLICATION_PATH . '/configs/application.ini'
);


$autoloader = Zend_Loader_Autoloader::getInstance();
$autoloader->setFallbackAutoloader(true);


$config = new Zend_Config_Ini(APPLICATION_PATH . '/configs/application.ini');
Zend_Registry::set('config', $config);

$db = Zend_Db::factory( $config->db->adapter, array(
		'host'     => $config->db->database->host,
		'username' => $config->db->database->username,
		'password' => $config->db->database->password,
		'dbname'   => $config->db->database->name
));
Zend_Registry::set('my_db', $db);
Zend_Db_Table_Abstract::setDefaultAdapter($db);

$sql="set names utf8";
$db->query($sql);

Zend_Layout::startMvc(APPLICATION_PATH . 'layouts/scripts/');
$zend_view   =   Zend_Layout::getMvcInstance()->getView();
$zend_view->addHelperPath('/View/Helper' , 'View_Helper');





$application->bootstrap()
            ->run();